<?php
    include('./dbconn.php');

    $title = $_GET["title"];

    if($title){
        $sql = "select * from midata where title='$title' order by Id desc";
    }else{
        $sql = "select * from midata order by Id desc";
    }
    
    // echo $title;
    $result = $conn->query($sql);
    if($result->num_rows > 0){
        for($i=0; $i<$result->num_rows; $i++){
            $list[] = mysqli_fetch_assoc($result);
        }
        $data["list"] = $list;
        $data["code"] = 0;
    }else{
        $data["code"] = 1;
    }
    echo json_encode($data);
?>